//
//  ZYVisitorViewController.swift
//  WBBeta1
//
//  Created by wustzhy on 16/8/10.
//  Copyright © 2016年 Yestin. All rights reserved.
//

import UIKit

class ZYVisitorViewController: UIViewController {
    //首页tableview
    lazy var tableview:UITableView = UITableView()//在homeVC中处理数据展示
    
    var isLogin:Bool = ZYUserAccountViewModel.sharedTools.isLogin
    
    var visitorView:ZYVisitorView?    //提供给子类调用setupVisitorViewInfo方法
    
    override func loadView() {
        if isLogin {
//            super.loadView()
            view = tableview
        }else{
            setupVistorView()
        }
    }

    func setupVistorView(){
        visitorView = ZYVisitorView(frame: UIScreen.mainScreen().bounds)
        self.view = visitorView
        
        visitorView?.closureVST = {
            self.loginAction()
        }
        setupNav()
    }
    
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
    }
    
    func loginAction(){
//        self.presentViewController(ZYOAuthViewController(), animated: false) { () -> Void in
//        }
        presentViewController(UINavigationController(rootViewController: ZYOAuthViewController()), animated: false) { () -> Void in
            
        }
    }
    
}
